import sys

f1 = open(sys.argv[1])
f2 = open(sys.argv[2])

l1 = f1.readline()
l2 = f2.readline()
while len(l1) > 0:
    l1 = l1.strip()
    l2 = l2.strip()
    p1 = l1.split()
    p2 = l2.split()
    r1 = int(p1[2])
    r2 = int(p2[2])
    
    r = r1 | r2
    print p1[0] , p1[1] , r

    l1 = f1.readline()
    l2 = f2.readline()

f1.close()
f2.close()
